package han.chensing.latos.common.level.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Objects;

public class ReflectUtil {
    public static boolean judgeAbstractType(Object object,Class<?>... classes){
        try {
            Class<?> aClass = object.getClass();
            Type genericSuperclass = aClass.getGenericSuperclass();
            ParameterizedType type = (ParameterizedType) genericSuperclass;
            Type[] actualTypeArguments = type.getActualTypeArguments();
            if (actualTypeArguments.length!=classes.length) return false;
            for (int i = 0; i < actualTypeArguments.length; i++)
                if (!Objects.equals(actualTypeArguments[i],classes[i])) return false;
            return true;
        }catch (Exception ignore){
            return false;
        }
    }
}
